﻿using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;

public class ShaPanProtocol : MonoBehaviour
{

    public static ShaPanProtocol ins;
    const int sleepTime = 500;
    [SerializeField]
    FHClientController rRClient;

    private void OnEnable()
    {
        ins = this;
    }
    private void OnDisable()
    {

    }

    const string On00 = "01 05 00 00 FF 00 8C 3A";
    const string Off00 = "01 05 00 00 00 00 CD CA";
    const string On01 = "01 05 00 01 FF 00 DD FA";
    const string Off01 = "01 05 00 01 00 00 9C 0A";
    const string On02 = "01 05 00 02 FF 00 2D FA";
    const string Off02 = "01 05 00 02 00 00 6C 0A";
    const string On03 = "01 05 00 03 FF 00 7C 3A";
    const string Off03 = "01 05 00 03 00 00 3D CA";
    const string On04 = "01 05 00 04 FF 00 CD FB";
    const string Off04 = "01 05 00 04 00 00 8C 0B";
    const string On05 = "01 05 00 05 FF 00 9C 3B";
    const string Off05 = "01 05 00 05 00 00 DD CB";
    const string On06 = "01 05 00 06 FF 00 6C 3B";
    const string Off06 = "01 05 00 06 00 00 2D CB";
    const string On07 = "01 05 00 07 FF 00 3D FB";
    const string Off07 = "01 05 00 07 00 00 7C 0B";
    const string On08 = "01 05 00 08 FF 00 0D F8";
    const string Off08 = "01 05 00 08 00 00 4C 08";
    const string On09 = "01 05 00 09 FF 00 5C 38";
    const string Off09 = "01 05 00 09 00 00 1D C8";
    const string On0A = "01 05 00 0A FF 00 AC 38";
    const string Off0A = "01 05 00 0A 00 00 ED C8";
    const string On0B = "01 05 00 0B FF 00 FD F8";
    const string Off0B = "01 05 00 0B 00 00 BC 08";
    const string On0C = "01 05 00 0C FF 00 4C 39";
    const string Off0C = "01 05 00 0C 00 00 0D C9";
    const string On0D = "01 05 00 0D FF 00 1D F9";
    const string Off0D = "01 05 00 0D 00 00 5C 09";
    const string On0E = "01 05 00 0E FF 00 ED F9";
    const string Off0E = "01 05 00 0E 00 00 AC 09";
    const string On0F = "01 05 00 0F FF 00 BC 39";
    const string Off0F = "01 05 00 0F 00 00 FD C9";
    const string On10 = "01 05 00 10 FF 00 8D FF";
    const string Off10 = "01 05 00 10 00 00 CC 0F";
    const string On11 = "01 05 00 11 FF 00 DC 3F";
    const string Off11 = "01 05 00 11 00 00 9D CF";
    const string On12 = "01 05 00 12 FF 00 2C 3F";
    const string Off12 = "01 05 00 12 00 00 6D CF";


    const string PowerOnPC = "AE 20 CF 29 03 FF FF 00 AC";
    const string PowerOffPC = "AE 20 CF 29 03 FF 00 00 AC";

    const string PowerOnTouYing = "AF 00 00 00 10 01 00 00 00 00 00 00 00 00 00 00 00 00 00 C0";
    const string PowerOffTouYing = "AF 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BF";


    /// <summary>
    /// 开启周围沙盘灯光 包括未来之门灯光
    /// </summary>
    public void OpenShapanLight()
    {
        Loom.RunAsync(() =>
        {
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On06);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On00);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, On04);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On01);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, On09);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On02);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, On0A);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On03);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, On0B);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On04);
            //rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, On0C);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On05);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, On0D);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On08);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, On10);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, On09);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, On11);
        });
    }
    /// <summary>
    /// 关闭沙盘周围灯光
    /// </summary>
    public void CloseShapanLight()
    {
        Loom.RunAsync(() =>
        {
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, Off06);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, Off10);//高质智慧城灯带
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, Off00);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, Off09);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, Off01);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, Off0A);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, Off02);
            //rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, Off0C);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, Off0B);//未来之城灯带
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, Off03);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, Off0D);
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, Off08);
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, Off04);//未来之城和高质智慧城文字灯
            Thread.Sleep(sleepTime);
            rRClient.SendHex(DataTypeEnum.LG20001, OrderTypeEnum.Str, Off09);//高品文旅城文字灯
            rRClient.SendHex(DataTypeEnum.LG20002, OrderTypeEnum.Str, Off11);//高品文旅城灯带

        });
    }
}
